home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 2002 November / SGI IRIX 6.5 Applications 2002 November.iso / dist / gateway.idb / usr / WebFace / Tasks / Tasks.security-start.cgi.z / Tasks.security-start.cgi
Encoding:
Text File  |  2002-06-12  |  6.8 KB  |  230 lines

  1. #!/usr/bin/perl5
  2. #
  3. # Tasks.security-start.cgi
  4. #
  5. # Copyright 1988-1996 Silicon Graphics, Inc.
  6. # All rights reserved.
  7. #
  8. # This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  9. # the contents of this file may not be disclosed to third parties, copied or
  10. # duplicated in any form, in whole or in part, without the prior written
  11. # permission of Silicon Graphics, Inc.
  12. #
  13. # RESTRICTED RIGHTS LEGEND:
  14. # Use, duplication or disclosure by the Government is subject to restrictions
  15. # as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  16. # and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  17. # successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  18. # rights reserved under the Copyright Laws of the United States.
  19. #
  20. # $Id: Tasks.security-start.cgi,v 1.10 1998/02/21 03:40:52 jrw Exp $
  21.  
  22. require "/usr/OnRamp/lib/OnRamp.pm";
  23.  
  24. $inet_conf = "/etc/inetd.conf";
  25. $temp = "task.tmp";
  26. $temp2 = "task.tmp2";
  27. $temp3 = "task.tmp3";
  28. $temp4 = "task.tmp4";
  29. $action = "Tasks.security-start.cgi?loop";
  30. $go = "/tasks/security-second.cgi?st";
  31.  
  32. $it = "<td><font size=5><i>";
  33. $ni = "</i></font></td>";
  34.  
  35. @find_vals = ('telnet','login','shell','ftp','finger');
  36.  
  37. &get_fields;
  38.  
  39. # clear temporary files for initial call
  40. if (!$ARGV[0]) {
  41.     open(OUT,"> $temp");
  42.     close(OUT);
  43.     open(OUT,"> $temp2");
  44.     close(OUT);
  45.     open(OUT,"> $temp3");
  46.     close(OUT);
  47.     open(OUT,"> $temp4");
  48.     close(OUT);
  49. #    &initValues;
  50. } elsif ($ARGV[0] eq 'loop') { %vals = %fld;  }
  51. else { &readValues; }
  52.  
  53. if ($ARGV[0] eq loop) {
  54.     &errorCheck;
  55.     &writeFile;
  56.  
  57.     print "Content-type: text/html\n\n";
  58.     # printf("Location: %s%c%c",$go,10,10);
  59.     print "<HTML><HEAD>";
  60.     print "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=$go\">";
  61.     print "</HEAD><BODY></BODY></HTML>";
  62.     exit 0;
  63. }
  64.  
  65. &setBoxes;
  66. &generic;
  67.  
  68. sub initValues {
  69.     open(IN,"< $inet_conf");
  70.     while(<IN>) {
  71.         $line = $_;
  72.         if ($line eq "\n") { next; }
  73.         $line =~ /^\s*(\S.*)/;
  74.         @items = split(/\s+/,$1);
  75.         if ($items[0] !~ "#") { $terms{$items[0]} = 1; } 
  76.         else { $terms{$items[0]} = 0; }
  77.     }
  78.     close(IN);
  79.     foreach $arg (@find_vals) {
  80.         if ($arg =~ $_) { $vals{$arg} = $terms{$arg}; }
  81.         else { $vals{$arg} = 0; }
  82.     }
  83. }
  84.  
  85. sub readValues {
  86.     open(IN,"< $temp");
  87.     while(<IN>) {
  88.         chop;
  89.         $terms{$_} = 1;
  90.     }
  91.     close(IN);
  92.     foreach $arg (@find_vals) {
  93.         if ($terms{$arg}) { $vals{$arg} = 1; }
  94.         else { $vals{$arg} = 0; }
  95.     }
  96.     if ($terms{"all_inetd"}) { $vals{"all_inetd"} = 1; }
  97.     else { $vals{"all_inetd"} = 0; }
  98. }
  99.  
  100. sub writeFile {
  101.     undef %terms;
  102.     open(IN,"< $temp");
  103.     while(<IN>) {
  104.         chop;
  105.         $terms{$_} = 1;
  106.     }
  107.     close(IN);
  108.  
  109.     if ($fld{'all_inetd'} == 1) { 
  110.         $terms{'all_inetd'} = 1;
  111.         foreach $arg (@find_vals) { $terms{$arg} = $fld{$arg}; }
  112.     } else {
  113.         $terms{'all_inetd'} = 0;
  114.         foreach $arg (@find_vals) { $terms{$arg} = 0; }
  115.     }
  116.  
  117.     open(OUT,"> $temp");
  118.     foreach $arg (keys(%terms)) {
  119.         print OUT "$arg\n" if ($terms{$arg} == 1);
  120.     }
  121.     close(OUT);
  122. }
  123.  
  124. sub errorCheck {
  125. }
  126.  
  127. sub error {
  128.     $error = $_[0];
  129.     &generic;
  130.     exit 0;
  131. }
  132.  
  133. sub generic {
  134.     print "Content-type: text/html\n\n";
  135.     print "<html><head><title>Security Setup </title>\n";
  136.     print "<script language=\"JavaScript\">\n<!--\n";
  137.  
  138.     # JavaScript
  139. print "function Next()  {
  140.     form = document.page1;
  141.     setTimeout('form.submit()',0);
  142.     return;
  143. }
  144. function errorBox (Ctrl, ErrorMessage) {
  145.     alert (ErrorMessage);  Ctrl.focus();  return;
  146. }\n";
  147.  
  148.     print "//-->\n";
  149.     print "</script></head>\n\n";
  150.  
  151.     print "<body bgcolor=\'a7b4ce\' background=/tasks/security-task.bg.gif>\n";
  152.     if ($error) {
  153.         print "<font size=4 color=ff0000><b>Error: </b>$error<br></font>";
  154.     }
  155.     print "<i>$message</i>";
  156.  
  157.     print "<table width=100%>",
  158.           "<tr><th align=left><h1>Security Setup for Services</h1></th>\n",
  159.           "<th align=right><a href=\"/newsplash.shtml\">",
  160.           "<img height=55 width=57 border=0 src=/tasks/home.gif></a>\n",
  161.           "  <a href=\"Tasks.shtml\">",
  162.           "<img height=55 width=57 border=0 src=/tasks/back.gif></a>",
  163.           "</tr></table>\n";
  164.  
  165.     printf("\n<form name=\"page1\" action=\"%s\" method=post>\n", $action);
  166.     
  167.     print "<center><table width=620>\n";
  168.  
  169.     print "<tr><td colspan=2 align=left>
  170.     Many services on the Internet Gateway are started by a master
  171.     server, inetd, which invokes a network service when it receives a
  172.     request for it.  These services, which are listed in the
  173.     configuration file <I>/etc/inetd.conf</I>, can pose security risks.
  174.     The Security Setup for Services form allows you to disable these
  175.     services.
  176.     <P>
  177.     You can use this page to disable services such as talk, time, and
  178.     echo (for a complete list, consult your copy of
  179.     <I>/etc/inetd.conf</I>).  If you do not make any selections on this
  180.     page, all services that inetd manages will remain enabled.  If you
  181.     choose to disable network services started out of inetd by checking
  182.     the box below, you can still leave up to five services enabled by
  183.     checking the appropriate boxes in the list. 
  184.     </td></tr></table>\n";
  185.  
  186.     print "<table width=520>\n";
  187.  
  188.     print "<tr><td colspan=2><input type=checkbox name=all_inetd value=1 $chall> ",
  189.           "  <strong>Disable network services started out of inetd</strong><br></td>",
  190.           "</tr><tr><td><br><br></td></tr></table>\n\n";
  191.  
  192.     print "<table width=620>\n";
  193.     print "<tr><td colspan=2>Leave enabled the following services:</td></tr>";
  194.     print "</table><table width=520>\n";
  195.  
  196.     print "<tr><td><input type=checkbox name=ftp value=1 $chftp> "
  197.         ."ftp (File Transfer Protocol.)</td></tr>";
  198.  
  199.     print "<tr><td><input type=checkbox name=telnet value=1 $chtelnet> telnet"
  200.         ." (Internet standard for remote login.)</td></tr>\n";
  201.  
  202.     print "<tr><td><input type=checkbox name=shell value=1 $chshell> shell"
  203.         ." (remote execution of shell commands.)</td></tr>\n";
  204.  
  205.     print "<tr><td><input type=checkbox name=login value=1 $chlogin> "
  206.         ."login (UNIX standard for remote login.)</td></tr>\n";
  207.  
  208.     print "<tr><td><input type=checkbox name=finger value=1 $chfinger> "
  209.         ."finger (remote query of user account information.)</td></tr>\n";
  210.  
  211.     print "</table></center>\n\n";
  212.  
  213.     print '<MAP NAME="js_map">',
  214.     '<AREA SHAPE="rect" COORDS="0,0,59,52" HREF="javascript:Next()">',
  215.     '</MAP>';
  216.     print "\n";
  217.     print '<IMG SRC="/tasks/rightarrow.gif" BORDER=0 USEMAP="#js_map" align="right">';
  218.  
  219.     print "\n</form></body></html>";
  220. }
  221.  
  222. sub setBoxes {
  223.     $chall = $vals{'all_inetd'} ? "checked" : "";
  224.     $chtelnet = $vals{'telnet'} ? "checked" : "";
  225.     $chlogin = $vals{'login'} ? "checked" : "";
  226.     $chshell = $vals{'shell'} ? "checked" : "";
  227.     $chftp = $vals{'ftp'} ? "checked" : "";
  228.     $chfinger = $vals{'finger'} ? "checked" : "";
  229. }
  230.